package com.syn.synold4s.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.gaoyi.basemodule.basebean.Event;
import com.gaoyi.basemodule.baseconstant.EventCode;

import org.greenrobot.eventbus.EventBus;

public class MqttNotifyReceiver extends BroadcastReceiver {
    public static final String MY_ACTION = "com.syn.synold4s.MqttNotifyReceiver";
    public static final String WEARER = "wearer";
    public static final String TEL = "tel";
    public static final String ADDRESS = "address";
    public static final String TYPE = "type";
    public static final String ALERT_TIME = "alertTime";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction() == null) {
            return;
        }
        if (intent.getAction().equals(MY_ACTION)) {
            EventBus.getDefault().post(new Event(EventCode.EVENT_ALERT,
                    intent.getStringExtra(WEARER),
                    intent.getStringExtra(TEL),
                    intent.getStringExtra(ADDRESS),
                    intent.getStringExtra(TYPE),
                    intent.getStringExtra(ALERT_TIME)));
        }
    }
}
